﻿<Window x:Class="PurchaseSales.Manage.Views.LoginView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
        Title="Login" Height="300" Width="400" WindowStartupLocation="CenterScreen" 
        AllowsTransparency="True" WindowStyle="None" x:Name="LoginWindow" >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="70"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" MouseDown="StackPanel_MouseDown" Background="LightGray">
            <Rectangle Height="40" VerticalAlignment="Center" Width="16" Fill="Green"/>
            <TextBlock Text="进销管理系统" VerticalAlignment="Center" Margin="5 0" FontSize="24" FontFamily="Microsoft YaHei"/>
        </StackPanel>
        <Canvas>
             <Button Content="X" ToolTip="Close" Height="20" Click="Button_Click" Width="20" Canvas.Right="0" Canvas.Top="0" />
        </Canvas>
       

        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="3*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Image HorizontalAlignment="Right" Width="80" Height="80" VerticalAlignment="Top"
                   Source="/Resources/Images/User With Frame.png" Grid.Row="1" />
            <StackPanel Grid.Column="1" Margin="5,1,0,0" Grid.Row="1">
                <TextBox x:Name="username" Controls:TextboxHelper.Watermark="UserName" Margin="0 0 30 0" TabIndex="1"
                         Text="{Binding UserName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                <DockPanel >
                    <Button Content="Go" DockPanel.Dock="Right" Margin="0 5 0 0" Command="{Binding LoginCommand}" 
                            CommandParameter="{Binding ElementName=LoginWindow}" TabIndex="3" IsDefault="True"/>
                    <PasswordBox x:Name="pb" Controls:TextboxHelper.Watermark="Password" TabIndex="2"  Margin="0 5 5 0">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="PasswordChanged">
                                <i:InvokeCommandAction Command="{Binding PasswordChangedCommand}" 
                                                       CommandParameter="{Binding ElementName=pb}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </PasswordBox>
                </DockPanel>

                <TextBlock Text="{Binding MessageError}" Foreground="Red" FontFamily="Microsoft YaHei" Margin="0 10"/>
            </StackPanel>
        </Grid>
    </Grid>
</Window>
